package sql;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.MessageFormat;

public class RegisterJDBC {
    static  JDBC_T jdbc_t;
    public void initial(){
        jdbc_t = new JDBC_T();
        if(jdbc_t.is_conn()){
            System.out.println("注册时连接数据库成功");
        }
    }
    public static boolean register(String username,String password,String gender,String address,String birthday ,String identity){
       String sql = MessageFormat.format("INSERT INTO request (username,pass,birth,gender,address,identity)\n" +
               " VALUES ({0}{1}{0},{0}{2}{0},{0}{3}{0},{0}{4}{0},{0}{5}{0},{0}{6}{0});",'"',username,password,birthday,gender,address,identity);
        System.out.println(sql);
        try{
            PreparedStatement preparedStatement = jdbc_t.getConn().prepareStatement(sql);
            preparedStatement.execute();

        }catch (SQLException sqlException){
            sqlException.printStackTrace();
            return false;
        }
        finally {
            return true;
        }
    }
    }

